package net.sourceforge.m2settings;

import java.io.FileNotFoundException;
import java.io.Reader;
import java.io.Writer;

import net.sourceforge.m2settings.model.Settings;

import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.InputSource;

public class SettingsXMLBinder extends XMLBinder {
	private Settings settings;
	
	public SettingsXMLBinder() throws FileNotFoundException, MarshalException, ValidationException {
		settings=new Settings();
	}
	

	public Settings getSettings() {
		return settings;
	}


	public void setSettings(Settings settings) {
		this.settings = settings;
	}


	public void readSettings(InputSource xmlSettingsIS) throws MarshalException, ValidationException {
		Unmarshaller um=new Unmarshaller(Settings.class);
		settings= (Settings)um.unmarshal(xmlSettingsIS);
	}
	
	public void readSettings(Reader xmlSettingsReader) throws MarshalException, ValidationException {
		Unmarshaller um=new Unmarshaller(Settings.class);
		settings= (Settings) um.unmarshal(xmlSettingsReader);
	}


	public void writeSettings(Writer writer) throws MarshalException, ValidationException {
		Marshaller.marshal(settings, writer);
		
	}

}
